#include <stdio.h> 
#include <stdlib.h> 

int main(void){ 
	int i, j, count, form_count, first; 
	char c; 
	FILE *f = fopen("output.txt", "w+");
	FILE *output = stdout;
	form_count = 1;
	first = 1;

	while( (scanf("%d %d", &i, &j))==2 && i != 0 && j != 0){
		int **mine_arr = (int **)malloc(sizeof(int *) * i ); 
		int k, l; 

		for(k = 0; k < i; k++) 
			mine_arr[k] = (int *)malloc(sizeof(int) * j); 
		
		k = l = 0;
		
		while(scanf("%c", &c) == 1 && k < i){ 
			if(c == '\n') continue;
			mine_arr[k][l] = (c=='*') ? 1 : 0; 
			l++;
			if(l == j){ 
				k++;
				l = 0;
			}
		}
		if(first)
			first = 0;
		else
			fprintf(output, "\n");
		fprintf(output, "Field #%d:", form_count); 

		form_count++;
			for(k = 0; k < i; k++){ 
				fprintf(output, "\n");
				for(l = 0; l < j; l++){ 
					count = 0;

					if(mine_arr[k][l]){ 
						fprintf(output, "*"); 
						continue; 
					}

					if(k != 0){ 
						if(l != 0) 
							if(mine_arr[k-1][l-1]) count++; 

						if(l != j-1) 
							if(mine_arr[k-1][l+1]) count++; 

						if(mine_arr[k-1][l]) count++; 
					}

					if(l != 0) 
						if(mine_arr[k][l-1]) count++; 

					if(l != j-1) 
						if(mine_arr[k][l+1]) count++; 

					if(k != i-1){ 

						if(l != 0) 
							if(mine_arr[k+1][l-1]) count++; 

						if(l != j-1) 
							if(mine_arr[k+1][l+1]) count++; 

						if(mine_arr[k+1][l]) count++;
					}
			fprintf(output, "%d", count); 
			}
		}
		fprintf(output, "\n");
	}
	return(0); 
}